#include <iostream>
#include <memory>
#include <string>
#include <jsoncpp/json/json.h>


//反序列化

int main()
{
    std::string str = R"({"姓名":"小黑","年龄":19,"成绩":[58.5,66,35.5]})";
    Json::Value root;
    
    Json::CharReaderBuilder crb;
    std::unique_ptr<Json::CharReader> cr(crb.newCharReader());

    bool ret = cr->parse(str.c_str(),str.c_str() + str.size(),&root,&str);
    if(ret == false)
    {
        std::cout<<"parse error\n";
    }
    
    std::cout<<"姓名："<<root["姓名"]<<std::endl;
    std::cout<<"年龄："<<root["年龄"]<<std::endl;
    std::cout<<"成绩：\n";

    int sz = root["成绩"].size();
    for(int i = 0;i < sz;i++)
    {
        std::cout<<root["成绩"][i]<<std::endl;
    }
    return 0;
}